* ##############################################
* 2017 JUNE SURVEY SETUP
* ##############################################

** Load the data
use "Data/omnibus_2017.dta"
codebook qTO qOBL qS1 qS2 qS3 q41A q41B q42C qD1A qD1B qD8, compact 

** Recode Survey Variables 
*Gender
recode qS1 (1=0 "male") (2=1 "female"), gen (gender) 

*Age
gen age=qS2
gen agesq=age*age

*Education 
gen education=qS3

*Navalny attitudes
recode q41A (1=1) (2=0), gen (knows_nav)
codebook q41B, tab (50) 
recode q41B (1=1) (2=2) (3/4=0) (5=3) (.=3), gen (leader_attitudes)

*Past vote 
codebook qD1A, tab (50)
recode qD1A (1=1) (2/3=0), gen (voter)
codebook qD1B, tab (50)
recode qD1B (4=1) (1/3=0) (5/17=0) (.=2), gen(vote_cast)

*Subjective income, pocketbook indicator
codebook qD8
recode qD8 (1/2=0) (3/6=1), gen (betteroff)

*Attitudes towards protesters 
codebook q42C, tab (50)
recode q42C (1=4) (2=3) (5=.) (3=2) (4=1), gen (supp_dem) 
recode q42C (1=5) (2=4) (5=3) (3=2) (4=1), gen (dem_supp) 
recode q42C (1/2=1) (3/4=0) (5=.), gen (dem_supp_dum) 
recode q42C (1/4=0) (5=1), gen (nonans)

*Moscow/ St Petersburg
recode qOBL (87/88=1) (else=0), gen (moscowstp)

codebook gender age agesq education knows_nav supp_dem dem_supp nonans dem_supp_dum voter vote_cast betteroff moscowstp leader_attitudes qTO qTOno qOBL qOBLno, compact


*Authorized protest indicator
tab authorised /*0=unauthorized fully, 1=authorized, 2=unauthorized,other times&locations*/
recode authorised (.=3), gen (auth_all)
codebook auth_all, tab(50)
recode auth_all (0=0) (1=1) (2=0) (3=2), gen (auth_t)
tab (auth_t)
recode auth_t (0=1) (1=0) (2=2), gen (auth_rev) /*recode so that unauthorized==1*/

*Arrest indicator
tab arrests
recode arrests (1/900=1) (.=0), gen (arrested_d)
tab arrested_d

*Authorized/ Arrests status combined 
gen type=.
replace type=1 if auth_t==1 & arrested_d==0 /*auth+no arrest*/
replace type=2 if auth_t==1 & arrested_d==1 /*auth+arrests*/
replace type=3 if auth_t==0 & arrested_d==0 /*unauthorized + no arrest*/
replace type=4 if auth_t==0 & arrested_d==1 /*unauthorized + arrests*/
replace type=5 if auth_t==2


*Report Summary Statistics
codebook gender age agesq education supp_dem dem_supp nonans dem_supp_dum vote_cast betteroff  leader_attitudes qTO qTOno civil_soc auth_t type logothers, compact

